package cn.felord.core.mongo.bean;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;

/**
 * @author Dax
 * @since 22:34  2018/5/22
 */
public class FileEntity implements Serializable {
    private static final long serialVersionUID = -1501115674979511150L;
    private String originalFilename;
    private byte[] data;
    private String contentType;
    private String name;
    private long  crtTime;

    public String getOriginalFilename() {
        return originalFilename;
    }

    public void setOriginalFilename(String originalFilename) {
        this.originalFilename = originalFilename;
    }

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getCrtTime() {
        return crtTime;
    }

    public void setCrtTime(long crtTime) {
        this.crtTime = crtTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        FileEntity that = (FileEntity) o;
        return crtTime == that.crtTime &&
                Objects.equals(originalFilename, that.originalFilename) &&
                Arrays.equals(data, that.data) &&
                Objects.equals(contentType, that.contentType) &&
                Objects.equals(name, that.name);
    }

    @Override
    public int hashCode() {

        int result = Objects.hash(originalFilename, contentType, name, crtTime);
        result = 31 * result + Arrays.hashCode(data);
        return result;
    }

    @Override
    public String toString() {
        return "{" +
                "originalFilename:" + originalFilename +
                ", data:" + Arrays.toString(data) +
                ", contentType:" + contentType +
                ", name:" + name +
                ", crtTime:" + crtTime +
                '}';
    }
}
